#
#	genx_cfg.py
#
#	David Janes
#	2008.08.16
#
#	GenX - search, create and insert structured data
#

import sys
import pprint
import types
import os
import os.path
import socket
import traceback

import bm_work
import bm_cfg

verbose = bool(__name__ == '__main__')

#
#	Do not change these: edit $HOME/.cfg/genx.cfg
#
cfg = {
	"home_uri" : "http://localhost/~davidjanes/genx/",
	"home_path" : "/Users/davidjanes/Sites/genx",
	"chmod_file" : 0777,
	"chmod_dir" : 0777,

    "gencard" : {
        "cite" : {
            "class" : "gencard-cite",
            "style" : "",
        },
        "gencard" : {
            "class" : "gencard",
            "style" : "border: 1px solid rgb(80, 161, 82); width: 100%; padding: 5px; margin: 5px 0px 5px 0px;",
        },
    },
}

#
#	Get the user's private configuration
#
bm_cfg.cfg.initialize()

d = bm_cfg.cfg.get("genx")
if d:
	cfg.update(d)

## developer_user = os.environ.get('USER') or 'nobody'
## developer_hostname = os.environ.get('HOSTNAME') or socket.gethostname() or ''
## developer_key = "%s@%s" % ( developer_user, developer_hostname.replace('.', '-'), )
## 
## developer_d = cfg.get(developer_key)
## if developer_d and type(developer_d) == types.DictType:
## 	if verbose:
## 		print >> sys.stderr, "loading developer data '%s'" % developer_key
## 
## 	cfg.update(developer_d)
## else:
## 	if verbose:
## 		print >> sys.stderr, "did not find developer key '%s'" % developer_key
## 
## if cfg.get("private_cfg") and os.path.isfile(cfg.get("private_cfg")):
## 	try:
## 		data = eval(open(cfg.get("private_cfg")).read())
## 		if data:
## 			if verbose:
## 				print >> sys.stderr, "loading private_cfg '%s'" % cfg.get("private_cfg")
## 
## 			cfg.update(data)
## 	except:
## 		print >> sys.stderr, "cannot open or read:", cfg.get("private_cfg")
## 		traceback.print_exc(file = sys.stderr)
## 
## 
## #
## #	Extended path
## #
## for module in cfg.get('modules') or []:
## 	path = os.path.join(cfg["home_path"], module)
## 	if path not in sys.path:
## 		sys.path.insert(0, path)

if __name__ == '__main__':
	pprint.pprint(cfg)
